library(here)
library(haven)
coalitions <- read_dta(here("pw_coalitions.dta"))

library(dplyr)

# testing for separation or quasi-separation in the data # 
# visual inspection (scatterplot)
plot(coalitions$shiftloser, coalitions$failure)

# separation test
library(brglm2)
coalition_sep<-glm(failure~maxshift+losercinctvc+shiftloser, family=binomial(link="probit"), 
                   data=coalitions, method="detect_separation")
coalition_sep

# results indicate no separation #

# uncomment this section to run omitting missing data# 
#coalitions_drop<-na.omit(coalitions)
#dim(coalitions_drop)
#plot(coalitions_drop$shiftloser, coalitions_drop$failure)
#coalition_drop_sep<-glm(failure~maxshift+losercinctvc+shiftloser, family=binomial(link="probit"), 
#                      data=coalitions_drop, method="detect_separation")
#coalition_drop_sep
